<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  #draw-border {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
  }

  button {
    box-sizing: border-box;
    position: relative;
    color: #4361ee;
    font-weight: bold;
    border: 0;
    padding: 10px 20px;
    background: none;   /* 去除button 自带的背景样式和border*/
    text-transform: uppercase;
    outline: none;
  }

  button::before, button::after {
    box-sizing: border-box;
    position: absolute;
    width: 0;
    height: 0;
    content: '';
    border: 2px solid transparent;
  }

  button::after {
    bottom: 0;
    right: 0;
  }

  button::before {
    top: 0;
    left: 0;
  }

  /* 规定 transition 动画过后达到的距离 */
  button:hover::before, button:hover::after {
    width: 100%;
    height: 100%;
  }

  button:hover::before {
    border-top-color: #4361ee;
    border-right-color: #4361ee;
    transition: width 0.3s ease-out, height 0.3s ease-out 0.3s;
  }

  button:hover::after {
    border-bottom-color: #4361ee;
    border-left-color: #4361ee;
    transition: border-color 0s ease-out 0.6s, width 0.3s ease-out 0.6s, height 0.3s ease-out 1s;
  }
</style>
<body>
  
  <div id="draw-border">
    <button>Hover me</button>
  </div>
</body>
</html>